libxc: Fix Segmentation fault of xend
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 21 Jun 2010 08:55:12 +0000 (09:55 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 21 Jun 2010 08:55:12 +0000 (09:55 +0100)
If /proc/xen/privcmd cannot be opened,
start xend occurs Segmentation fault.
Add check to fix it.

Signed-off-by: Yu Zhiguo <yuzg@cn.fujitsu.com>
tools/libxc/xc_private.c

index 9761b98af4b1db0152bab2658f522cf073d043ee..13a990a58c156258604f34979b1e9167a8c7c557 100644 (file)
@@ -82,8 +82,10 @@ const xc_error *xc_get_last_error(xc_interface *xch)
 
 void xc_clear_last_error(xc_interface *xch)
 {
-    xch->last_error.code = XC_ERROR_NONE;
-    xch->last_error.message[0] = '\0';
+    if (xch) {
+        xch->last_error.code = XC_ERROR_NONE;
+        xch->last_error.message[0] = '\0';
+    }
 }
 
 const char *xc_error_code_to_desc(int code)